package com.spring.shops.service.impl;

import com.spring.shops.dao.TzSysLogMapper;
import com.spring.shops.model.dto.SysLogDTO;
import com.spring.shops.model.entity.TzSysLog;
import com.spring.shops.model.vo.SysLogVo;
import com.spring.shops.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysLogServiceImpl implements SysLogService {
    @Autowired
    private TzSysLogMapper tzSysLogMapper;

    @Override
    public SysLogVo page(SysLogVo sysLogVo, String username, String operation) {
        SysLogDTO sysLogDTO = new SysLogDTO();
        sysLogDTO.setUsername(username);
        sysLogDTO.setOperation(operation);
        int size = Integer.parseInt(sysLogVo.getSize());
        sysLogDTO.setSize(size);
        int current = Integer.parseInt(sysLogVo.getCurrent());
        sysLogDTO.setCurrent(current-1);

        TzSysLog[] getpage = tzSysLogMapper.getpage(sysLogDTO);
        long total =getpage .length;
        sysLogVo.setTotal(total);
        System.out.println(getpage.length);
        sysLogVo.setRecords(getpage);
        return sysLogVo;
    }
}
